<!DOCTYPE html>
<html lang="zh" dir="ltr" class="client-nojs">
<head>
<title>工具库</title>
<meta charset="UTF-8">
<meta name="generator" content="MediaWiki 1.21.2">
<link rel="shortcut icon" href="../../common/favicon.ico">
<link rel="stylesheet" href="../../common/ext.css">
<meta name="ResourceLoaderDynamicStyles" content="">
<link rel="stylesheet" href="../../common/site_modules.css">
<style>a:lang(ar),a:lang(ckb),a:lang(fa),a:lang(kk-arab),a:lang(mzn),a:lang(ps),a:lang(ur){text-decoration:none}#toc{display:none}.editsection{display:none}
/* cache key: mwiki1-mwiki_zh_:resourceloader:filter:minify-css:7:15cea3ec788a65b5187d4018eed543bf */</style>

<script src="../../common/startup_scripts.js"></script>
<script>if(window.mw){
mw.config.set({"wgCanonicalNamespace":"","wgCanonicalSpecialPageName":false,"wgNamespaceNumber":0,"wgPageName":"cpp/utility","wgTitle":"cpp/utility","wgCurRevisionId":64863,"wgArticleId":4040,"wgIsArticle":true,"wgAction":"view","wgUserName":null,"wgUserGroups":["*"],"wgCategories":[],"wgBreakFrames":false,"wgPageContentLanguage":"zh","wgSeparatorTransformTable":["",""],"wgDigitTransformTable":["",""],"wgDefaultDateFormat":"zh","wgMonthNames":["","1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"],"wgMonthNamesShort":["","1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"],"wgRelevantPageName":"cpp/utility","wgUserVariant":"zh","wgRestrictionEdit":[],"wgRestrictionMove":[]});
}</script><script>if(window.mw){
mw.loader.implement("user.options",function(){mw.user.options.set({"ccmeonemails":0,"cols":80,"date":"default","diffonly":0,"disablemail":0,"disablesuggest":0,"editfont":"default","editondblclick":0,"editsection":0,"editsectiononrightclick":0,"enotifminoredits":0,"enotifrevealaddr":0,"enotifusertalkpages":1,"enotifwatchlistpages":0,"extendwatchlist":0,"externaldiff":0,"externaleditor":0,"fancysig":0,"forceeditsummary":0,"gender":"unknown","hideminor":0,"hidepatrolled":0,"imagesize":2,"justify":0,"math":1,"minordefault":0,"newpageshidepatrolled":0,"nocache":0,"noconvertlink":0,"norollbackdiff":0,"numberheadings":0,"previewonfirst":0,"previewontop":1,"quickbar":5,"rcdays":7,"rclimit":50,"rememberpassword":0,"rows":25,"searchlimit":20,"showhiddencats":0,"showjumplinks":1,"shownumberswatching":1,"showtoc":0,"showtoolbar":1,"skin":"cppreference2","stubthreshold":0,"thumbsize":2,"underline":2,"uselivepreview":0,"usenewrc":0,"watchcreations":0,"watchdefault":0,"watchdeletion":0,
"watchlistdays":3,"watchlisthideanons":0,"watchlisthidebots":0,"watchlisthideliu":0,"watchlisthideminor":0,"watchlisthideown":0,"watchlisthidepatrolled":0,"watchmoves":0,"wllimit":250,"variant":"zh","language":"zh","searchNs0":true,"searchNs1":false,"searchNs2":false,"searchNs3":false,"searchNs4":false,"searchNs5":false,"searchNs6":false,"searchNs7":false,"searchNs8":false,"searchNs9":false,"searchNs10":false,"searchNs11":false,"searchNs12":false,"searchNs13":false,"searchNs14":false,"searchNs15":false,"gadget-MathJax":1,"gadget-ColiruCompiler":1});;},{},{});mw.loader.implement("user.tokens",function(){mw.user.tokens.set({"editToken":"+\\","patrolToken":false,"watchToken":false});;},{},{});
/* cache key: mwiki1-mwiki_zh_:resourceloader:filter:minify-js:7:258d7cd6aa9aa67dee25e01fb6a9e505 */
}</script>
<script>if(window.mw){
mw.loader.load(["mediawiki.page.startup","mediawiki.legacy.wikibits","mediawiki.legacy.ajax"]);
}</script>
<style type="text/css">/*<![CDATA[*/
.source-cpp {line-height: normal;}
.source-cpp li, .source-cpp pre {
	line-height: normal; border: 0px none white;
}
/**
 * GeSHi Dynamically Generated Stylesheet
 * --------------------------------------
 * Dynamically generated stylesheet for cpp
 * CSS class: source-cpp, CSS id: 
 * GeSHi (C) 2004 - 2007 Nigel McNie, 2007 - 2008 Benny Baumann
 * (http://qbnz.com/highlighter/ and http://geshi.org/)
 * --------------------------------------
 */
.cpp.source-cpp .de1, .cpp.source-cpp .de2 {font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;}
.cpp.source-cpp  {font-family:monospace;}
.cpp.source-cpp .imp {font-weight: bold; color: red;}
.cpp.source-cpp li, .cpp.source-cpp .li1 {font-weight: normal; vertical-align:top;}
.cpp.source-cpp .ln {width:1px;text-align:right;margin:0;padding:0 2px;vertical-align:top;}
.cpp.source-cpp .li2 {font-weight: bold; vertical-align:top;}
.cpp.source-cpp .kw1 {color: #0000dd;}
.cpp.source-cpp .kw2 {color: #0000ff;}
.cpp.source-cpp .kw3 {color: #0000dd;}
.cpp.source-cpp .kw4 {color: #0000ff;}
.cpp.source-cpp .co1 {color: #909090;}
.cpp.source-cpp .co2 {color: #339900;}
.cpp.source-cpp .coMULTI {color: #ff0000; font-style: italic;}
.cpp.source-cpp .es0 {color: #008000; font-weight: bold;}
.cpp.source-cpp .es1 {color: #008000; font-weight: bold;}
.cpp.source-cpp .es2 {color: #008000; font-weight: bold;}
.cpp.source-cpp .es3 {color: #008000; font-weight: bold;}
.cpp.source-cpp .es4 {color: #008000; font-weight: bold;}
.cpp.source-cpp .es5 {color: #008000; font-weight: bold;}
.cpp.source-cpp .br0 {color: #008000;}
.cpp.source-cpp .sy0 {color: #008000;}
.cpp.source-cpp .sy1 {color: #000080;}
.cpp.source-cpp .sy2 {color: #000040;}
.cpp.source-cpp .sy3 {color: #000040;}
.cpp.source-cpp .sy4 {color: #008080;}
.cpp.source-cpp .st0 {color: #008000;}
.cpp.source-cpp .nu0 {color: #000080;}
.cpp.source-cpp .nu6 {color: #000080;}
.cpp.source-cpp .nu8 {color: #000080;}
.cpp.source-cpp .nu12 {color: #000080;}
.cpp.source-cpp .nu16 {color:#000080;}
.cpp.source-cpp .nu17 {color:#000080;}
.cpp.source-cpp .nu18 {color:#000080;}
.cpp.source-cpp .nu19 {color:#000080;}
.cpp.source-cpp .ln-xtra, .cpp.source-cpp li.ln-xtra, .cpp.source-cpp div.ln-xtra {background-color: #ffc;}
.cpp.source-cpp span.xtra { display:block; }

/*]]>*/
</style><!--[if lt IE 7]><style type="text/css">body{behavior:url("/mwiki/skins/cppreference2/csshover.min.htc")}</style><![endif]--></head>
<body class="mediawiki ltr sitedir-ltr ns-0 ns-subject page-cpp_utility skin-cppreference2 action-view cpp-navbar">
        <!-- header -->
        <!-- /header -->
        <!-- content -->
<div id="cpp-content-base">
            <div id="content">
                <a id="top"></a>
                <div id="mw-js-message" style="display:none;"></div>
                                <!-- firstHeading -->
<h1 id="firstHeading" class="firstHeading">工具库</h1>
                <!-- /firstHeading -->
                <!-- bodyContent -->
                <div id="bodyContent">
                                        <!-- tagline -->
                    <div id="siteSub">来自cppreference.com</div>
                    <!-- /tagline -->
                                        <!-- subtitle -->
                    <div id="contentSub"><span class="subpages">&lt; <a href="../cpp.html" title="cpp">cpp</a></span></div>
                    <!-- /subtitle -->
                                                            <!-- bodycontent -->
                    <div id="mw-content-text" lang="zh" dir="ltr" class="mw-content-ltr"><div class="t-navbar" style=""><div class="t-navbar-sep"> </div><div class="t-navbar-head"><a href="../cpp.html" title="cpp"> C++</a><div class="t-navbar-menu"><div><div><table class="t-nv-begin" cellpadding="0" style="line-height:1.1em;">
<tr class="t-nv"><td colspan="5"> <a href="language.html" title="cpp/language">语言</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="header.html" title="cpp/header">标准库头文件</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="freestanding.html" title="cpp/freestanding"> 自立与有宿主实现</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="named_req.html" title="cpp/named req">具名要求</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="utility.html#.E8.AF.AD.E8.A8.80.E6.94.AF.E6.8C.81" title="cpp/utility">语言支持库</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="concepts.html" title="cpp/concepts">概念库</a> <span class="t-mark-rev t-since-cxx20">(C++20)</span> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="error.html" title="cpp/error">诊断库</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <strong class="selflink">工具库</strong> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="string.html" title="cpp/string">字符串库</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="https://zh.cppreference.com/w/cpp/container" title="cpp/container">容器库</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="iterator.html" title="cpp/iterator">迭代器库</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="ranges.html" title="cpp/ranges"> 范围库</a> <span class="t-mark-rev t-since-cxx20">(C++20)</span> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="algorithm.html" title="cpp/algorithm">算法库</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="numeric.html" title="cpp/numeric">数值库</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="io.html" title="cpp/io">输入/输出库</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="locale.html" title="cpp/locale">本地化库</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="regex.html" title="cpp/regex">正则表达式库</a> <span class="t-mark-rev t-since-cxx11">(C++11)</span> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="atomic.html" title="cpp/atomic">原子操作库</a> <span class="t-mark-rev t-since-cxx11">(C++11)</span> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="thread.html" title="cpp/thread">线程支持库</a> <span class="t-mark-rev t-since-cxx11">(C++11)</span> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="filesystem.html" title="cpp/filesystem">文件系统库</a> <span class="t-mark-rev t-since-cxx17">(C++17)</span> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="experimental.html" title="cpp/experimental">技术规范</a> </td></tr>
</table></div><div></div></div></div></div><div class="t-navbar-sep"> </div><div class="t-navbar-head"><strong class="selflink">工具库</strong><div class="t-navbar-menu"><div><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"> <a href="types.html" title="cpp/types">类型支持</a>（基本类型、 RTTI 、类型特性）</td></tr>
<tr class="t-nv"><td colspan="5"> <a href="memory.html" title="cpp/memory">动态内存管理</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="error.html" title="cpp/error">错误处理</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="utility/program.html" title="cpp/utility/program">程序工具</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="utility/variadic.html" title="cpp/utility/variadic">变参数函数</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="utility/feature_test.html" title="cpp/utility/feature test">库特性测试宏</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="chrono.html" title="cpp/chrono">日期和时间</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="utility/functional.html" title="cpp/utility/functional">函数对象</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="utility/format.html" title="cpp/utility/format"> 格式化库</a> <span class="t-mark-rev t-since-cxx20">(C++20)</span> </td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="utility/initializer_list.html" title="cpp/utility/initializer list"><span class="t-lines"><span>initializer_list</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="utility/source_location.html" title="cpp/utility/source location"><span class="t-lines"><span>source_location</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="utility/bitset.html" title="cpp/utility/bitset"><span class="t-lines"><span>bitset</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="utility/hash.html" title="cpp/utility/hash"><span class="t-lines"><span>hash</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="utility/integer_sequence.html" title="cpp/utility/integer sequence"><span class="t-lines"><span>integer_sequence</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx14">(C++14)</span></span></span></div></div></td></tr>
<tr class="t-nv-h2"><td colspan="5"> 关系运算符 <span class="t-mark-rev t-deprecated-cxx20">(C++20 中弃用)</span> </td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="utility/rel_ops/operator_cmp.html" title="cpp/utility/rel ops/operator cmp"><span class="t-lines"><span>rel_ops::operator!=</span><span>rel_ops::operator&gt;</span><span>rel_ops::operator&lt;=</span><span>rel_ops::operator&gt;=</span></span></a></div></div></td></tr>
<tr class="t-nv-h2"><td colspan="5"> 比较 <span class="t-mark-rev t-since-cxx20">(C++20)</span></td></tr><tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="utility/compare/three_way_comparable.html" title="cpp/utility/compare/three way comparable"><span class="t-lines"><span>three_way_comparable</span><span>three_way_comparable_with</span></span></a></div></div></td></tr>
<tr class="t-nv-col-table"><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="utility/compare/strong_ordering.html" title="cpp/utility/compare/strong ordering"><span class="t-lines"><span>strong_ordering</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="utility/compare/weak_ordering.html" title="cpp/utility/compare/weak ordering"><span class="t-lines"><span>weak_ordering</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="utility/compare/partial_ordering.html" title="cpp/utility/compare/partial ordering"><span class="t-lines"><span>partial_ordering</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="utility/compare/common_comparison_category.html" title="cpp/utility/compare/common comparison category"><span class="t-lines"><span>common_comparison_category</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="utility/compare/compare_three_way_result.html" title="cpp/utility/compare/compare three way result"><span class="t-lines"><span>compare_three_way_result</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="utility/compare/compare_three_way.html" title="cpp/utility/compare/compare three way"><span class="t-lines"><span>compare_three_way</span></span></a></div></div></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="utility/compare/strong_order.html" title="cpp/utility/compare/strong order"><span class="t-lines"><span>strong_order</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="utility/compare/weak_order.html" title="cpp/utility/compare/weak order"><span class="t-lines"><span>weak_order</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="utility/compare/partial_order.html" title="cpp/utility/compare/partial order"><span class="t-lines"><span>partial_order</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="utility/compare/compare_strong_order_fallback.html" title="cpp/utility/compare/compare strong order fallback"><span class="t-lines"><span>compare_strong_order_fallback</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="utility/compare/compare_weak_order_fallback.html" title="cpp/utility/compare/compare weak order fallback"><span class="t-lines"><span>compare_weak_order_fallback</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="utility/compare/compare_partial_order_fallback.html" title="cpp/utility/compare/compare partial order fallback"><span class="t-lines"><span>compare_partial_order_fallback</span></span></a></div></div></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="utility/compare/named_comparison_functions.html" title="cpp/utility/compare/named comparison functions"><span class="t-lines"><span>is_eq</span><span>is_neq</span><span>is_lt</span><span>is_lteq</span><span>is_gt</span><span>is_gteq</span></span></a></div></div></td></tr>
</table></div></td></tr>
<tr class="t-nv-h2"><td colspan="5"> 共用词汇类型</td></tr>
<tr class="t-nv-col-table"><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="utility/pair.html" title="cpp/utility/pair"><span class="t-lines"><span>pair</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="utility/tuple.html" title="cpp/utility/tuple"><span class="t-lines"><span>tuple</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="utility/apply.html" title="cpp/utility/apply"><span class="t-lines"><span>apply</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx17">(C++17)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="utility/make_from_tuple.html" title="cpp/utility/make from tuple"><span class="t-lines"><span>make_from_tuple</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx17">(C++17)</span></span></span></div></div></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="utility/optional.html" title="cpp/utility/optional"><span class="t-lines"><span>optional</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx17">(C++17)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="utility/any.html" title="cpp/utility/any"><span class="t-lines"><span>any</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx17">(C++17)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="utility/variant.html" title="cpp/utility/variant"><span class="t-lines"><span>variant</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx17">(C++17)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"> <br>
</td></tr>
</table></div></td></tr>
<tr class="t-nv-h2"><td colspan="5"> swap 、 forward 与 move</td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="algorithm/swap.html" title="cpp/algorithm/swap"><span class="t-lines"><span>swap</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="utility/exchange.html" title="cpp/utility/exchange"><span class="t-lines"><span>exchange</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx14">(C++14)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="utility/forward.html" title="cpp/utility/forward"><span class="t-lines"><span>forward</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="utility/move.html" title="cpp/utility/move"><span class="t-lines"><span>move</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="utility/move_if_noexcept.html" title="cpp/utility/move if noexcept"><span class="t-lines"><span>move_if_noexcept</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv-h2"><td colspan="5"> 初等字符串转换</td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="utility/to_chars.html" title="cpp/utility/to chars"><span class="t-lines"><span>to_chars</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx17">(C++17)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="utility/from_chars.html" title="cpp/utility/from chars"><span class="t-lines"><span>from_chars</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx17">(C++17)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="utility/chars_format.html" title="cpp/utility/chars format"><span class="t-lines"><span>chars_format</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx17">(C++17)</span></span></span></div></div></td></tr>
<tr class="t-nv-h2"><td colspan="5"> 类型运算</td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="utility/declval.html" title="cpp/utility/declval"><span class="t-lines"><span>declval</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="utility/as_const.html" title="cpp/utility/as const"><span class="t-lines"><span>as_const</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx17">(C++17)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="utility/launder.html" title="cpp/utility/launder"><span class="t-lines"><span>launder</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx17">(C++17)</span></span></span></div></div></td></tr>
</table></div><div></div></div></div></div><div class="t-navbar-sep"> </div></div>
<p>C++ 包含了各种工具库，提供了诸如<a href="utility/bitset.html" title="cpp/utility/bitset">位计数</a>和<a href="utility/functional/bind.html" title="cpp/utility/functional/bind">部分函数应用</a>的功能。这些库大致可以分为两类：
</p>
<ul><li> 语言支持库
</li><li> 通用库
</li></ul>
<p><br>
</p>
<h2><span class="mw-headline" id=".E8.AF.AD.E8.A8.80.E6.94.AF.E6.8C.81">语言支持</span></h2>
<p>语言支持库中所提供的类和函数与语言特性紧密相关，用以支持语言中的一些常见的惯用法。
</p>
<h3><span class="mw-headline" id=".E7.B1.BB.E5.9E.8B.E6.94.AF.E6.8C.81"><a href="types.html" title="cpp/types">类型支持</a></span></h3>
<p>基本类型（如 <span class="t-lc"><a href="types/size_t.html" title="cpp/types/size t">std::size_t</a></span> 、 <span class="t-lc"><a href="types/nullptr_t.html" title="cpp/types/nullptr t">std::nullptr_t</a></span> ）、 RTTI （如 <span class="t-lc"><a href="types/type_info.html" title="cpp/types/type info">std::type_info</a></span> ）、类型特性（如 <span class="t-lc"><a href="types/is_integral.html" title="cpp/types/is integral">std::is_integral</a></span> 、 <span class="t-lc"><a href="types/rank.html" title="cpp/types/rank">std::rank</a></span> ）。
</p>
<h3><span class="mw-headline" id=".E5.8A.A8.E6.80.81.E5.86.85.E5.AD.98.E7.AE.A1.E7.90.86"><a href="memory.html" title="cpp/memory">动态内存管理</a></span></h3>
<p>智能指针（如 <span class="t-lc"><a href="memory/shared_ptr.html" title="cpp/memory/shared ptr">std::shared_ptr</a></span> ）、分配器（如 <span class="t-lc"><a href="memory/allocator.html" title="cpp/memory/allocator">std::allocator</a></span> 或 <span class="t-lc"><a href="memory/memory_resource.html" title="cpp/memory/memory resource">std::pmr::memory_resource</a></span> ）、C 风格内存管理（如 <span class="t-lc"><a href="memory/c/malloc.html" title="cpp/memory/c/malloc">std::malloc</a></span> ）。
</p>
<h3><span class="mw-headline" id=".E9.94.99.E8.AF.AF.E5.A4.84.E7.90.86"><a href="error.html" title="cpp/error">错误处理</a></span></h3>
<p>异常（如 <span class="t-lc"><a href="error/exception.html" title="cpp/error/exception">std::exception</a></span>、<span class="t-lc"><a href="error/terminate.html" title="cpp/error/terminate">std::terminate</a></span> ）、断言（如 <span class="t-lc"><a href="error/assert.html" title="cpp/error/assert">assert</a></span> ）。
</p>
<h3><span class="mw-headline" id=".E5.88.9D.E5.A7.8B.E5.8C.96.E5.99.A8.E5.88.97.E8.A1.A8">初始化器列表</span></h3>
<table class="t-dsc-begin">

<tr class="t-dsc-header">
<td colspan="2"> <div>定义于头文件 <code>&lt;initializer_list&gt;</code> </div>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="utility/initializer_list.html" title="cpp/utility/initializer list"> <span class="t-lines"><span>initializer_list</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div>
</td>
<td>  允许使用<a href="language/list_initialization.html" title="cpp/language/list initialization">初始化器列表语法</a>初始化非聚合体类型 <br> <span class="t-mark">(类模板)</span> </td></tr>
</table>
<h3><span class="mw-headline" id=".E5.8F.98.E5.8F.82.E6.95.B0.E5.87.BD.E6.95.B0"><a href="utility/variadic.html" title="cpp/utility/variadic">变参数函数</a></span></h3>
<p>支持接受任意数量参数的函数（例如通过 <span class="t-lc"><a href="utility/variadic/va_start.html" title="cpp/utility/variadic/va start">va_start</a></span> 、 <span class="t-lc"><a href="utility/variadic/va_arg.html" title="cpp/utility/variadic/va arg">va_arg</a></span> 、 <span class="t-lc"><a href="utility/variadic/va_end.html" title="cpp/utility/variadic/va end">va_end</a></span> ）。
</p>
 <table class="t-rev-begin">
<tr class="t-rev t-since-cxx20"><td>
<h3> <span class="mw-headline" id=".E5.AE.9E.E7.8E.B0.E5.B1.9E.E6.80.A7">实现属性</span></h3>
<p>头文件 <a href="header/version.html" title="cpp/header/version"><tt>&lt;version&gt;</tt></a> 提供关于 C++ 标准库的实现依赖信息（例如版本号和发行日期）。它亦定义<a href="utility/feature_test.html" title="cpp/utility/feature test">特性测试宏</a>。
</p>
<h3> <span class="mw-headline" id=".E6.BA.90.E7.A0.81.E4.BF.A1.E6.81.AF.E6.8D.95.E8.8E.B7">源码信息捕获</span></h3>
<table class="t-dsc-begin">

<tr class="t-dsc-header">
<td colspan="2"> <div>定义于头文件 <code>&lt;source_location&gt;</code> </div>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="utility/source_location.html" title="cpp/utility/source location"> <span class="t-lines"><span>source_location</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div>
</td>
<td>  表示关于源码的信息，例如文件名、行号以及函数名的类 <br> <span class="t-mark">(类)</span> </td></tr>
</table>
</td>
<td><span class="t-mark-rev t-since-cxx20">(C++20 起)</span></td></tr>
</table>
<h2><span class="mw-headline" id=".E9.80.9A.E7.94.A8.E5.B7.A5.E5.85.B7">通用工具</span></h2>
<h3><span class="mw-headline" id=".E7.A8.8B.E5.BA.8F.E5.B7.A5.E5.85.B7"><a href="utility/program.html" title="cpp/utility/program">程序工具</a></span></h3>
<p>终止（如 <span class="t-lc"><a href="utility/program/abort.html" title="cpp/utility/program/abort">std::abort</a></span> 、 <span class="t-lc"><a href="utility/program/atexit.html" title="cpp/utility/program/atexit">std::atexit</a></span> ）、环境（如 <span class="t-lc"><a href="utility/program/system.html" title="cpp/utility/program/system">std::system</a></span> ）、信号（如 <span class="t-lc"><a href="utility/program/raise.html" title="cpp/utility/program/raise">std::raise</a></span> ）。
</p>
<h3><span class="mw-headline" id=".E6.97.A5.E6.9C.9F.E5.92.8C.E6.97.B6.E9.97.B4"><a href="chrono.html" title="cpp/chrono">日期和时间</a></span></h3>
<p>时间跟踪（如 <span class="t-lc"><a href="chrono/time_point.html" title="cpp/chrono/time point">std::chrono::time_point</a></span> 、 <span class="t-lc"><a href="chrono/duration.html" title="cpp/chrono/duration">std::chrono::duration</a></span> ）， C 风格日期和时间（如 <span class="t-lc"><a href="chrono/c/time.html" title="cpp/chrono/c/time">std::time</a></span> 、 <span class="t-lc"><a href="chrono/c/clock.html" title="cpp/chrono/c/clock">std::clock</a></span> ）。
</p>
<h3><span class="mw-headline" id=".E4.BD.8D.E9.9B.86.E5.90.88">位集合</span></h3>
<table class="t-dsc-begin">

<tr class="t-dsc-header">
<td colspan="2"> <div>定义于头文件 <code>&lt;bitset&gt;</code> </div>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="utility/bitset.html" title="cpp/utility/bitset"> <span class="t-lines"><span>bitset</span></span></a></div></div>
</td>
<td>  实现常量长度的位数组 <br> <span class="t-mark">(类)</span> </td></tr>
</table>
<h3><span class="mw-headline" id=".E5.87.BD.E6.95.B0.E5.AF.B9.E8.B1.A1"><a href="utility/functional.html" title="cpp/utility/functional">函数对象</a></span></h3>
<p>部分函数应用（如 <span class="t-lc"><a href="utility/functional/bind.html" title="cpp/utility/functional/bind">std::bind</a></span> ）及相关工具：用于绑定的工具，如 <span class="t-lc"><a href="utility/functional/ref.html" title="cpp/utility/functional/ref">std::ref</a></span> 与 <span class="t-lc"><a href="utility/functional/placeholders.html" title="cpp/utility/functional/placeholders">std::placeholders</a></span> 、多态函数包装器： <span class="t-lc"><a href="utility/functional/function.html" title="cpp/utility/functional/function">std::function</a></span> 、预定义函数对象（如 <span class="t-lc"><a href="utility/functional/plus.html" title="cpp/utility/functional/plus">std::plus</a></span> 、 <span class="t-lc"><a href="utility/functional/equal_to.html" title="cpp/utility/functional/equal to">std::equal_to</a></span> ）、方法到函数转换器 <span class="t-lc"><a href="utility/functional/mem_fn.html" title="cpp/utility/functional/mem fn">std::mem_fn</a></span> 。
</p>
<h3><span class="mw-headline" id="optional_.E3.80.81_variant_.E4.B8.8E_any">optional 、 variant 与 any</span></h3>
<table class="t-dsc-begin">

<tr class="t-dsc-header">
<td colspan="2"> <div>定义于头文件 <code>&lt;optional&gt;</code> </div>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="utility/optional.html" title="cpp/utility/optional"> <span class="t-lines"><span>optional</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx17">(C++17 起)</span></span></span></div></div>
</td>
<td>   可能或可能不保有一个对象的包装器  <br> <span class="t-mark">(类模板)</span> </td></tr>

<tr class="t-dsc-sep">
<td colspan="2">  
</td></tr>
<tr class="t-dsc-header">
<td colspan="2"> <div>定义于头文件 <code>&lt;variant&gt;</code> </div>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="utility/variant.html" title="cpp/utility/variant"> <span class="t-lines"><span>variant</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx17">(C++17 起)</span></span></span></div></div>
</td>
<td>   类型安全的可辨识联合体  <br> <span class="t-mark">(类模板)</span> </td></tr>

<tr class="t-dsc-sep">
<td colspan="2">  
</td></tr>
<tr class="t-dsc-header">
<td colspan="2"> <div>定义于头文件 <code>&lt;any&gt;</code> </div>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="utility/any.html" title="cpp/utility/any"> <span class="t-lines"><span>any</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx17">(C++17 起)</span></span></span></div></div>
</td>
<td>   可保有任何<a href="named_req/CopyConstructible.html" title="cpp/named req/CopyConstructible"><i>可复制构造</i> <span style="font-family: Georgia, 'DejaVu Serif', serif; font-style:italic">(CopyConstructible)</span> </a>类型的实例的对象。 <br> <span class="t-mark">(类)</span> </td></tr>

<tr class="t-dsc-sep">
<td colspan="2">  
</td></tr>
<tr class="t-dsc-header">
<td colspan="2"> <div>定义于头文件 <code>&lt;utility&gt;</code> </div>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="utility/in_place.html" title="cpp/utility/in place"> <span class="t-lines"><span>in_place </span><span> in_place_type </span><span> in_place_index </span><span> in_place_t </span><span>in_place_type_t </span><span>in_place_index_t</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx17">(C++17)</span></span></span></div></div>
</td>
<td>   原位构造标签  <br> <span class="t-mark">(类模板)</span> </td></tr>
</table>
<h3><span class="mw-headline" id=".E5.AF.B9.E4.B8.8E.E5.85.83.E7.BB.84">对与元组</span></h3>
<table class="t-dsc-begin">

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="utility/pair.html" title="cpp/utility/pair"> <span class="t-lines"><span>pair</span></span></a></div></div>
</td>
<td>  实现二元组，即一对值 <br> <span class="t-mark">(类模板)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="utility/tuple.html" title="cpp/utility/tuple"> <span class="t-lines"><span>tuple</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div>
</td>
<td>  实现固定大小的容器，它保有类型可以相异的元素 <br> <span class="t-mark">(类模板)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="utility/apply.html" title="cpp/utility/apply"> <span class="t-lines"><span>apply</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx17">(C++17)</span></span></span></div></div>
</td>
<td>  以一个实参的元组来调用函数 <br> <span class="t-mark">(函数模板)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="utility/make_from_tuple.html" title="cpp/utility/make from tuple"> <span class="t-lines"><span>make_from_tuple</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx17">(C++17)</span></span></span></div></div>
</td>
<td>  以一个实参元组构造对象 <br> <span class="t-mark">(函数模板)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="utility/piecewise_construct_t.html" title="cpp/utility/piecewise construct t"> <span class="t-lines"><span>piecewise_construct_t</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div>
</td>
<td>  用于为逐段构造选择正确函数重载的标签类型 <br> <span class="t-mark">(类)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="utility/piecewise_construct.html" title="cpp/utility/piecewise construct"> <span class="t-lines"><span>piecewise_construct</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div>
</td>
<td>  用于为逐段构造的函数消歧义的 <code>piecewise_construct_t</code> 类型的对象 <br> <span class="t-mark">(常量)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="utility/integer_sequence.html" title="cpp/utility/integer sequence"> <span class="t-lines"><span>integer_sequence</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx14">(C++14)</span></span></span></div></div>
</td>
<td>  实现编译时整数数列 <br> <span class="t-mark">(类模板)</span> </td></tr>
</table>
<h3><span class="mw-headline" id="swap_.E3.80.81_forward_.E4.B8.8E_move">swap 、 forward 与 move</span></h3>
<table class="t-dsc-begin">

<tr class="t-dsc-header">
<td colspan="2"> <div>定义于头文件 <code>&lt;utility&gt;</code> </div>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="algorithm/swap.html" title="cpp/algorithm/swap"> <span class="t-lines"><span>swap</span></span></a></div></div>
</td>
<td>   交换两个对象的值  <br> <span class="t-mark">(函数模板)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="utility/exchange.html" title="cpp/utility/exchange"> <span class="t-lines"><span>exchange</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx14">(C++14)</span></span></span></div></div>
</td>
<td>  将实参替换为一个新值，并返回其先前值 <br> <span class="t-mark">(函数模板)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="utility/forward.html" title="cpp/utility/forward"> <span class="t-lines"><span>forward</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div>
</td>
<td>  转发一个函数实参 <br> <span class="t-mark">(函数模板)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="utility/move.html" title="cpp/utility/move"> <span class="t-lines"><span>move</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div>
</td>
<td>  获得右值引用 <br> <span class="t-mark">(函数模板)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="utility/move_if_noexcept.html" title="cpp/utility/move if noexcept"> <span class="t-lines"><span>move_if_noexcept</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div>
</td>
<td>  若移动构造函数不抛出则获得右值引用 <br> <span class="t-mark">(函数模板)</span> </td></tr>

<tr class="t-dsc-header">
<td colspan="2"> <div>定义于头文件 <code>&lt;concepts&gt;</code> </div>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="utility/ranges/swap.html" title="cpp/utility/ranges/swap"> <span class="t-lines"><span>ranges::swap</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div>
</td>
<td>  交换两个对象的值 <br> <span class="t-mark">(定制点对象)</span> </td></tr>
</table>
<h3><span class="mw-headline" id=".E7.B1.BB.E5.9E.8B.E8.BF.90.E7.AE.97">类型运算</span></h3>
<table class="t-dsc-begin">

<tr class="t-dsc-header">
<td colspan="2"> <div>定义于头文件 <code>&lt;utility&gt;</code> </div>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="utility/declval.html" title="cpp/utility/declval"> <span class="t-lines"><span>declval</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div>
</td>
<td>   获取到其实参的引用，用于不求值语境中 <br> <span class="t-mark">(函数模板)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="utility/as_const.html" title="cpp/utility/as const"> <span class="t-lines"><span>as_const</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx17">(C++17)</span></span></span></div></div>
</td>
<td>  获得到其实参的 const 引用 <br> <span class="t-mark">(函数模板)</span> </td></tr>

<tr class="t-dsc-sep">
<td colspan="2">  
</td></tr>
<tr class="t-dsc-header">
<td colspan="2"> <div>定义于头文件 <code>&lt;new&gt;</code> </div>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="utility/launder.html" title="cpp/utility/launder"> <span class="t-lines"><span>launder</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx17">(C++17)</span></span></span></div></div>
</td>
<td>  指针优化屏障 <br> <span class="t-mark">(函数模板)</span> </td></tr>
</table>
<h3><span class="mw-headline" id=".E5.85.B3.E7.B3.BB.E8.BF.90.E7.AE.97.E7.AC.A6.E4.B8.8E.E6.AF.94.E8.BE.83">关系运算符与比较</span></h3>
<table class="t-dsc-begin">

<tr class="t-dsc-header">
<td colspan="2"> <div>定义于头文件 <code>&lt;compare&gt;</code> </div>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="utility/compare/three_way_comparable.html" title="cpp/utility/compare/three way comparable"> <span class="t-lines"><span>three_way_comparable</span><span>three_way_comparable_with</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div>
</td>
<td>  指定运算符 <span class="t-c"><span class="mw-geshi cpp source-cpp"><span class="sy1">&lt;=&gt;</span></span></span> 在给定类型上产生一致的结果  <br> <span class="t-mark">(概念)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="utility/compare/partial_ordering.html" title="cpp/utility/compare/partial ordering"> <span class="t-lines"><span>partial_ordering</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div>
</td>
<td>  三路比较的结果类型，支持所有 6 种运算符，不可替换，并允许不可比较的值 <br> <span class="t-mark">(类)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="utility/compare/weak_ordering.html" title="cpp/utility/compare/weak ordering"> <span class="t-lines"><span>weak_ordering</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div>
</td>
<td>  三路比较的结果类型，支持所有 6 种运算符且不可替换 <br> <span class="t-mark">(类)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="utility/compare/strong_ordering.html" title="cpp/utility/compare/strong ordering"> <span class="t-lines"><span>strong_ordering</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div>
</td>
<td>  三路比较的结果类型，支持所有 6 种运算符且可替换 <br> <span class="t-mark">(类)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="utility/compare/named_comparison_functions.html" title="cpp/utility/compare/named comparison functions"> <span class="t-lines"><span>is_eq</span><span>is_neq</span><span>is_lt</span><span>is_lteq</span><span>is_gt</span><span>is_gteq</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div>
</td>
<td>  具名比较函数 <br> <span class="t-mark">(函数)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="utility/compare/compare_three_way.html" title="cpp/utility/compare/compare three way"> <span class="t-lines"><span>compare_three_way</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div>
</td>
<td>  实现 <span class="t-c"><span class="mw-geshi cpp source-cpp">x <span class="sy1">&lt;=&gt;</span> y</span></span> 的函数对象 <br> <span class="t-mark">(类)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="utility/compare/compare_three_way_result.html" title="cpp/utility/compare/compare three way result"> <span class="t-lines"><span>compare_three_way_result</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div>
</td>
<td>   获得三路比较运算符 <span class="t-c"><span class="mw-geshi cpp source-cpp"><span class="sy1">&lt;=&gt;</span></span></span> 在给定类型上的结果  <br> <span class="t-mark">(类模板)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="utility/compare/common_comparison_category.html" title="cpp/utility/compare/common comparison category"> <span class="t-lines"><span>common_comparison_category</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div>
</td>
<td>  给定的全部类型都能转换到的最强比较类别 <br> <span class="t-mark">(类模板)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="utility/compare/strong_order.html" title="cpp/utility/compare/strong order"> <span class="t-lines"><span>strong_order</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div>
</td>
<td>  进行三路比较并产生 <code>std::strong_ordering</code> 类型结果 <br> <span class="t-mark">(定制点对象)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="utility/compare/weak_order.html" title="cpp/utility/compare/weak order"> <span class="t-lines"><span>weak_order</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div>
</td>
<td>  进行三路比较并产生 <code>std::weak_ordering</code> 类型结果 <br> <span class="t-mark">(定制点对象)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="utility/compare/partial_order.html" title="cpp/utility/compare/partial order"> <span class="t-lines"><span>partial_order</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div>
</td>
<td>  进行三路比较并产生 <code>std::partial_ordering</code> 类型结果 <br> <span class="t-mark">(定制点对象)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="utility/compare/compare_strong_order_fallback.html" title="cpp/utility/compare/compare strong order fallback"> <span class="t-lines"><span>compare_strong_order_fallback</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div>
</td>
<td>  进行三路比较并产生 <code>std::strong_ordering</code> 类型的结果，即使 <span class="t-c"><span class="mw-geshi cpp source-cpp">operator<span class="sy1">&lt;=&gt;</span></span></span> 不可用 <br> <span class="t-mark">(定制点对象)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="utility/compare/compare_weak_order_fallback.html" title="cpp/utility/compare/compare weak order fallback"> <span class="t-lines"><span>compare_weak_order_fallback</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div>
</td>
<td>   进行三路比较并产生 <code>std::weak_ordering</code> 类型的结果，即使 <span class="t-c"><span class="mw-geshi cpp source-cpp">operator<span class="sy1">&lt;=&gt;</span></span></span> 不可用 <br> <span class="t-mark">(定制点对象)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="utility/compare/compare_partial_order_fallback.html" title="cpp/utility/compare/compare partial order fallback"> <span class="t-lines"><span>compare_partial_order_fallback</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div>
</td>
<td>  进行三路比较并产生 <code>std::partial_ordering</code> 类型的结果，即使 <span class="t-c"><span class="mw-geshi cpp source-cpp">operator<span class="sy1">&lt;=&gt;</span></span></span> 不可用 <br> <span class="t-mark">(定制点对象)</span> </td></tr>

<tr class="t-dsc-sep">
<td colspan="2">  
</td></tr>
<tr class="t-dsc-header">
<td colspan="2"> <div>定义于头文件 <code>&lt;utility&gt;</code> </div>
</td></tr>

<tr class="t-dsc-header">
<td colspan="2"> <div>定义于命名空间 <code>std::rel_ops</code></div>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="utility/rel_ops/operator_cmp.html" title="cpp/utility/rel ops/operator cmp"> <span class="t-lines"><span>operator!=</span><span>operator&gt;</span><span>operator&lt;=</span><span>operator&gt;=</span></span></a></div><div><span class="t-lines"><span><span class="t-mark">(C++20 中弃用)</span></span></span></div></div>
</td>
<td>  自动生成基于用户定义的 <span class="t-c"><span class="mw-geshi cpp source-cpp">operator<span class="sy1">==</span></span></span> 和 <span class="t-c"><span class="mw-geshi cpp source-cpp">operator<span class="sy1">&lt;</span></span></span> 的比较运算符 <br> <span class="t-mark">(函数模板)</span> </td></tr>
</table>
<h3><span class="mw-headline" id=".E5.88.9D.E7.AD.89.E5.AD.97.E7.AC.A6.E4.B8.B2.E8.BD.AC.E6.8D.A2">初等字符串转换</span></h3>
<p>除了 <a href="io.html" title="cpp/io">C++ I/O</a> 库、 <a href="io/c.html" title="cpp/io/c">C I/O</a> 库、 <a href="string/basic_string.html#.E6.95.B0.E5.80.BC.E8.BD.AC.E6.8D.A2" title="cpp/string/basic string">C++ 字符串转换函数</a>和 <a href="string/byte.html#.E8.BD.AC.E6.8D.A2.E4.B8.BA.E6.95.B0.E5.AD.97.E6.A0.BC.E5.BC.8F" title="cpp/string/byte">C 字符串转换函数</a>提供的复杂的本地环境依赖的分析器和格式化器外，头文件 <a href="header/charconv.html" title="cpp/header/charconv"><tt>&lt;charconv&gt;</tt></a> 提供对于算术类型的轻量、不依赖本地环境、不分配、不抛出、仅供 ASCII 的分析器和格式化器。
</p>
<table class="t-dsc-begin">

<tr class="t-dsc-header">
<td colspan="2"> <div>定义于头文件 <code>&lt;charconv&gt;</code> </div>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="utility/to_chars.html" title="cpp/utility/to chars"> <span class="t-lines"><span>to_chars</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx17">(C++17)</span></span></span></div></div>
</td>
<td>  转换整数或浮点值到字符序列 <br> <span class="t-mark">(函数)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="utility/from_chars.html" title="cpp/utility/from chars"> <span class="t-lines"><span>from_chars</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx17">(C++17)</span></span></span></div></div>
</td>
<td>  转换字符序列到整数或浮点值 <br> <span class="t-mark">(函数)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="utility/chars_format.html" title="cpp/utility/chars format"> <span class="t-lines"><span>chars_format</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx17">(C++17)</span></span></span></div></div>
</td>
<td>  指定 <span class="t-lc">std::to_chars</span> 和 <span class="t-lc">std::from_chars</span> 所用的格式 <br> <span class="t-mark">(枚举)</span> </td></tr>
</table>
<h3><span class="mw-headline" id=".E6.A0.BC.E5.BC.8F.E5.8C.96.E5.BA.93_.28C.2B.2B20_.E8.B5.B7.29"><a href="utility/format.html" title="cpp/utility/format">格式化库</a> <span class="t-mark-rev t-since-cxx20">(C++20 起)</span></span></h3>
<p>类型安全的字符串格式化工具，例如 <span class="t-lc">std::format</span> <span class="t-lc">std::format_to</span> 。
</p>
<h3><span class="mw-headline" id=".E6.95.A3.E5.88.97.E6.94.AF.E6.8C.81">散列支持</span></h3>
<table class="t-dsc-begin">

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="utility/hash.html" title="cpp/utility/hash"> <span class="t-lines"><span>hash</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div>
</td>
<td>  散列函数对象 <br> <span class="t-mark">(类模板)</span> </td></tr>
</table>

<!-- 
NewPP limit report
Preprocessor visited node count: 9741/1000000
Preprocessor generated node count: 12050/1000000
Post‐expand include size: 339761/2097152 bytes
Template argument size: 64836/2097152 bytes
Highest expansion depth: 23/40
Expensive parser function count: 0/100
-->

<!-- Saved in parser cache with key mwiki1-mwiki_zh_:pcache:idhash:4040-0!*!0!!zh!*!zh!* and timestamp 20200218131410 -->
</div>                    <!-- /bodycontent -->
                                        <!-- printfooter -->
                    <div class="printfooter">
                    来自“<a href="https://zh.cppreference.com/mwiki/index.php?title=cpp/utility&amp;oldid=64863">https://zh.cppreference.com/mwiki/index.php?title=cpp/utility&amp;oldid=64863</a>”                    </div>
                    <!-- /printfooter -->
                                                            <!-- catlinks -->
                    <!-- /catlinks -->
                                                            <div class="visualClear"></div>
                    <!-- debughtml -->
                                        <!-- /debughtml -->
                </div>
                <!-- /bodyContent -->
            </div>
        </div>
        <!-- /content -->
        <!-- footer -->
        <div id="cpp-footer-base" class="noprint">
            <div id="footer">
                        <div id="cpp-navigation">
            <h5>导航</h5>
            <ul><li><a href="https://zh.cppreference.com/w/cpp/utility">Online version</a></li><li>Offline version retrieved 2020-03-14 18:00.</li></ul></div>
                        <ul id="footer-info">
                                    <li id="footer-info-lastmod"> 本页面最后修改于2020年2月18日 (星期二) 05:14。</li>
                                    <li id="footer-info-viewcount">此页面已被浏览过68,560次。</li>
                            </ul>
                    </div>
        </div>
        <!-- /footer -->
        <script>if(window.mw){
mw.loader.state({"site":"loading","user":"missing","user.groups":"ready"});
}</script>
<script src="../../common/skin_scripts.js"></script>
<script>if(window.mw){
mw.loader.load(["mediawiki.action.view.postEdit","mediawiki.user","mediawiki.page.ready","mediawiki.searchSuggest","mediawiki.hidpi","ext.gadget.MathJax","ext.gadget.ColiruCompiler"], null, true);
}</script>
<script src="../../common/site_scripts.js"></script>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-2828341-1']);
_gaq.push(['_setDomainName', 'cppreference.com']);
_gaq.push(['_trackPageview']);
</script><!-- Served in 0.096 secs. -->
	</body>
<!-- Cached 20200218172650 -->
</html>